<#import '/ftlLibrary/properteisVariable.ftl' as pv/>
<link href="assets/css/bootstrap-select.css" rel="stylesheet"/>
<link href="assets/css/front/listCommonStyle.css" rel="stylesheet"/>
<script src="assets/js/select2/select2.js"></script>
<style>
    td, th {
        height: 34.29px !important;
    }

    .tssStudentModal .modal-dialog {
        width: 60%;
    }

    input {
        height: 30px !important;
    }

    .editFormDiv label {
        margin: 0 auto !important;
    }

    .editFormDiv .control-label {
        text-align: right;
        line-height: 25px;
    }
    .labelBorderTable label{
        margin:0;
        padding:0;
    }
</style>
<div class="row"  style="margin-left: 0px!important;">
    <div class="col-xs-6 col-xs-offset-3 ">
        <div class="col-xs-4 nopadding">
            <button type="btn" class="btn col-xs-12 " onclick="detailsSwitch(this)" flag="1" style="border-color: #5db2ff!important;float:left">费用明细</button>
        </div>
        <div class="col-xs-4 nopadding">
            <button type="btn" class="btn col-xs-12 " onclick="detailsSwitch(this)" flag="2" style="border-color: #5db2ff!important;background-color: #5db2ff;float:left">缴费记录</button>
        </div>
        <div class="col-xs-4 nopadding">
            <button type="btn" class="btn col-xs-12 " onclick="detailsSwitch(this)" flag="3" style="border-color: #5db2ff!important;float:left">退款记录</button>
        </div>
    </div>
    <!-- 映射列表 -->
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 labelBorderTable" style="margin-top: 15px">
        <label class="col-xs-4 text-align-center" style="border: 1px solid #ccc;border-bottom: none">
            <label class="col-xs-6" style="border-right: 1px solid #ccc;padding: 5px 0;">
                会员编号：
            </label>
            <label class="col-xs-6" style="padding: 5px 0">
                ${(viewStudentDetails.number???string(viewStudentDetails.number?html,"未设置"))!'未设置'}
            </label>
        </label>
        <label class="col-xs-4 text-align-center" style="border: 1px solid #ccc;border-left: none;border-bottom: none">
            <label class="col-xs-6" style="border-right: 1px solid #ccc;padding: 5px 0">
                客户姓名：
            </label>
            <label class="col-xs-6" style="padding: 5px 0">
                ${(viewStudentDetails.name???string(viewStudentDetails.name?html,"未设置"))!'未设置'}
            </label>
        </label>
        <label class="col-xs-4 text-align-center" style="border: 1px solid #ccc;border-left: none;border-bottom: none">
            <label class="col-xs-6" style="border-right: 1px solid #ccc;padding: 5px 0">
                会员性别：
            </label>
            <label class="col-xs-6" style="padding: 5px 0">
                ${(viewStudentDetails.sex???string(viewStudentDetails.sex?html,"未设置"))!'未设置'}
            </label>
        </label>

        <label class="col-xs-4 text-align-center" style="border: 1px solid #ccc;">
            <label class="col-xs-6" style="border-right: 1px solid #ccc;padding: 5px 0">
                联系电话：
            </label>
            <label class="col-xs-6" style="padding: 5px 0">
                ${(viewStudentDetails.contactPhone???string(viewStudentDetails.contactPhone?html,"未设置"))!'未设置'}
            </label>
        </label>
        <label class="col-xs-4 text-align-center" style="border: 1px solid #ccc;border-left: none">
            <label class="col-xs-6" style="border-right: 1px solid #ccc;padding: 5px 0">
                会员类型：
            </label>
            <label class="col-xs-6" style="padding: 5px 0">
                ${(viewStudentDetails.type???string(viewStudentDetails.type?html,"未设置"))!'未设置'}
            </label>
        </label>
        <label class="col-xs-4 text-align-center" style="border: 1px solid #ccc;border-left: none">
            <label class="col-xs-6" style="border-right: 1px solid #ccc;padding: 5px 0">
                所属顾问：
            </label>
            <label class="col-xs-6" style="padding: 5px 0">
                ${(viewStudentDetails.realName???string(viewStudentDetails.realName?html,"未设置"))!'未设置'}
            </label>
        </label>

        <label class="col-xs-4 text-align-center" style="border: 1px solid #ccc;border-top: none">
            <label class="col-xs-6" style="border-right: 1px solid #ccc;padding: 5px 0">
                缴费总额：
            </label>
            <label class="col-xs-6" style="padding: 5px 0">
                ${(viewStudentDetails.sumAmount???string(viewStudentDetails.sumAmount?html,"未设置"))!'未设置'}
            </label>
        </label>
        <label class="col-xs-4 text-align-center" style="border: 1px solid #ccc;border-left: none;border-top: none">
            <label class="col-xs-6" style="border-right: 1px solid #ccc;padding: 5px 0">
                退费总额：
            </label>
            <label class="col-xs-6" style="padding: 5px 0">
                ${(viewStudentDetails.refundAmout???string(viewStudentDetails.refundAmout?html,"未设置"))!'未设置'}
            </label>
        </label>
        <label class="col-xs-4 text-align-center" style="border: 1px solid #ccc;border-left: none;border-top: none">
            <label class="col-xs-6" style="border-right: 1px solid #ccc;padding: 5px 0">
                合计：
            </label>
            <label class="col-xs-6" style="padding: 5px 0">
                ${(viewStudentDetails.total???string(viewStudentDetails.total?html,"未设置"))!'未设置'}
            </label>
        </label>
    </div>
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 margin-top-20" style="height: 34.29px;line-height: 34.29px;background-color: #eee;padding: 0px 10px;border: 1px solid #ccc;border-bottom: none">
            <label class="pull-right" style="color: red">
                累计缴费：100000.00元
            </label>
        </div>
    </div>
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
        <div class="widget flat radius-bordered" style="margin-top: 0;box-shadow:0px 0px 10px rgba(122,161,184,0.3);!important;">
            <div class="widget-body no-padding">
                <div class="topPagingBar hidden">
                    <form>
                        <input type="hidden" name="checkboxId" id="checkboxId" value="0">
                        <input type="hidden" name="stuId" id="stuId" value="${stuId}">
                    </form>
                </div>
                <div class="table-scrollable">
                    <!-- 数据表列信息列表 -->
                    <table class="table table-bordered dataTable">
                        <thead>
                        <tr>
                            <th title="属性名">序号</th>
                            <th title="费用类型">费用类型</th>
                            <th title="合同编号">合同编号</th>
                            <th title="费用明细">费用明细</th>
                            <th title="报名状态">报名状态</th>
                            <th title="课时数">课时数</th>
                            <th title="缴费金额(元)">缴费金额(元)</th>
                            <th title="优惠金额">优惠金额</th>
                            <th title="赠品价值">赠品价值</th>
                            <th title="原单价">原单价</th>
                            <th title="折后单价">折后单价</th>
                            <th title="付款编号">付款编号</th>
                            <th title="操作时间">操作时间</th>
                            <th title="操作人">操作人</th>
                            <th title="备注">备注</th>
                        </tr>
                        </thead>
                        <tbody>
                        <#if packageDetailsList?size==0>
                            <#if DepositDetailsList?size==0>
                                <#if otherPaymentDetailsList?size==0>
                                    <tr>
                                        <td align="center">无数据</td>
                                    </tr>
                                </#if>
                            </#if>
                        </#if>
                        <#list packageDetailsList as data>
                                <tr class="${data.packageId}">
                                    <td>${(data.index???string(data.index?html,"未设置"))!'未设置'}</td>
                                    <#if data.paymentType==3>
                                        <td>
                                            <a href="javascript:void(0);" class="showtr" onclick="details(this)" packageId=${data.packageId}>+</a>
                                            ${(data.paymentType???string(data.paymentType?html,"未设置"))!'未设置'}
                                        </td>
                                    </#if>
                                    <#if data.paymentType!=3>
                                        ${(data.paymentType???string(data.paymentType?html,"未设置"))!'未设置'}
                                    </#if>
                                    <td>${(data.contractNumber???string(data.contractNumber?html,"未设置"))!'未设置'}</td>
                                    <td>${(data.packageName???string(data.packageName?html,"未设置"))!'未设置'}</td>
                                    <td>${(data.applyStatus???string(data.applyStatus?html,"未设置"))!'未设置'}</td>
                                    <#if data.type==1>
                                        <td>
                                            ${(data.totalClassHour???string(data.totalClassHour?html,"未设置"))!'未设置'}
                                            +
                                            ${(data.presentClassHour???string(data.presentClassHour?html,"未设置"))!'未设置'}
                                        </td>
                                     </#if>
                                    <#if data.type==2>
                                        <td>
                                            ${(data.attendanceDay???string(data.attendanceDay?html,"未设置"))!'未设置'}
                                            +
                                            ${(data.giftAttendanceDay???string(data.giftAttendanceDay?html,"未设置"))!'未设置'}
                                        </td>
                                     </#if>
                                    <td>${(data.sumPrice???string(data.sumPrice?html,"未设置"))!'未设置'}</td>
                                    <td>${(data.discountedPrice???string(data.discountedPrice?html,"未设置"))!'未设置'}</td>
                                    <td>${(data.gifts???string(data.gifts?html,"未设置"))!'未设置'}</td>
                                    <td>${(data.originalUnitPrice???string(data.originalUnitPrice?html,"未设置"))!'未设置'}</td>
                                    <td>${(data.nowUnitPrice???string(data.nowUnitPrice?html,"未设置"))!'未设置'}</td>
                                    <td>${(data.paymentCode???string(data.paymentCode?html,"未设置"))!'未设置'}</td>
                                    <td>${(data.updateTime???string(data.updateTime?html,"未设置"))!'未设置'}</td>
                                    <td>${(data.userName???string(data.userName?html,"未设置"))!'未设置'}</td>
                                    <td>${(data.remark???string(data.remark?html,"未设置"))!'未设置'}</td>
                                </tr>
                            <!--<#if data.paymentType!=3>
                                <tr>
                                    <td>${(data.index???string(data.index?html,"未设置"))!'未设置'}</td>
                                    <td>
                                        ${(data.paymentType???string(data.paymentType?html,"未设置"))!'未设置'}
                                    </td>
                                    <td>${(data.contractNumber???string(data.contractNumber?html,"未设置"))!'未设置'}</td>
                                    <td>${(data.packageName???string(data.packageName?html,"未设置"))!'未设置'}</td>
                                    <td>${(data.applyStatus???string(data.applyStatus?html,"未设置"))!'未设置'}</td>
                                    <td>${(data.sumPrice???string(data.sumPrice?html,"未设置"))!'未设置'}</td>
                                    <td>${(data.discountedPrice???string(data.discountedPrice?html,"未设置"))!'未设置'}</td>
                                    <td>${(data.paymentCode???string(data.paymentCode?html,"未设置"))!'未设置'}</td>
                                    <td>${(data.updateTime???string(data.updateTime?html,"未设置"))!'未设置'}</td>
                                    <td>${(data.userName???string(data.userName?html,"未设置"))!'未设置'}</td>
                                    <td>${(data.remark???string(data.remark?html,"未设置"))!'未设置'}</td>
                                </tr>
                            </#if>-->
                        </#list>
                        <#list DepositDetailsList as data>
                            <tr>
                                <td>${(data.index???string(data.index?html,"未设置"))!'未设置'}</td>
                                <td>${(data.paymentType???string(data.paymentType?html,"未设置"))!'未设置'}</td>
                                <td>${(data.contractNumber???string(data.contractNumber?html,"未设置"))!'未设置'}</td>
                                <td>${(data.paymentType???string(data.paymentType?html,"未设置"))!'未设置'}</td>
                                <td>${(data.applyStatus???string(data.applyStatus?html,"未设置"))!'未设置'}</td>
                                <td></td>
                                <td>${(data.amount???string(data.amount?html,"未设置"))!'未设置'}</td>
                                <td>${(data.discountedPrice???string(data.discountedPrice?html,"未设置"))!'未设置'}</td>
                                <td>${(data.gifts???string(data.gifts?html,"未设置"))!'未设置'}</td>
                                <td>${(data.originalUnitPrice???string(data.originalUnitPrice?html,"未设置"))!'未设置'}</td>
                                <td>${(data.nowUnitPrice???string(data.nowUnitPrice?html,"未设置"))!'未设置'}</td>
                                <td>${(data.paymentCode???string(data.paymentCode?html,"未设置"))!'未设置'}</td>
                                <td>${(data.updateTime???string(data.updateTime?html,"未设置"))!'未设置'}</td>
                                <td>${(data.userName???string(data.userName?html,"未设置"))!'未设置'}</td>
                                <td>${(data.remark???string(data.remark?html,"未设置"))!'未设置'}</td>
                            </tr>
                        </#list>
                        <#list otherPaymentDetailsList as data>
                            <tr>
                                <td>${(data.index???string(data.index?html,"未设置"))!'未设置'}</td>
                                <td>${(data.paymentType???string(data.paymentType?html,"未设置"))!'未设置'}</td>
                                <td>${(data.contractNumber???string(data.contractNumber?html,"未设置"))!'未设置'}</td>
                                <td>${(data.paymentType???string(data.paymentType?html,"未设置"))!'未设置'}</td>
                                <td>${(data.applyStatus???string(data.applyStatus?html,"未设置"))!'未设置'}</td>
                                <td></td>
                                <td>${(data.amount???string(data.amount?html,"未设置"))!'未设置'}</td>
                                <td>${(data.discountedPrice???string(data.discountedPrice?html,"未设置"))!'未设置'}</td>
                                <td>${(data.gifts???string(data.gifts?html,"未设置"))!'未设置'}</td>
                                <td>${(data.originalUnitPrice???string(data.originalUnitPrice?html,"未设置"))!'未设置'}</td>
                                <td>${(data.nowUnitPrice???string(data.nowUnitPrice?html,"未设置"))!'未设置'}</td>
                                <td>${(data.paymentCode???string(data.paymentCode?html,"未设置"))!'未设置'}</td>
                                <td>${(data.updateTime???string(data.updateTime?html,"未设置"))!'未设置'}</td>
                                <td>${(data.userName???string(data.userName?html,"未设置"))!'未设置'}</td>
                                <td>${(data.remark???string(data.remark?html,"未设置"))!'未设置'}</td>

                            </tr>
                        </#list>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>


    </div>
</div>
<script>
    $(".selectpicker").select2();

    var zxc = false;

    $(function () {
        $(".showtr").trigger("click");

        var showFlag = $("#showFlag").val();
        if(showFlag == 1){
            $(".showFlag").removeClass("hidden").addClass("show");
        }
    })

    function detailsSwitch(that) {
        var flag = $(that).attr("flag");
        var stuId = $("#stuId").val();
        var htmlTitle= "";
        var url = "";
        if(flag == "1"){
            htmlTitle= "费用明细";
            url="tssPaymentController/chargeDetails.do";
        }
        if(flag == "2"){
            htmlTitle= "缴费记录";
            url="tssPaymentController/ViewPaymentDetails.do";
        }
        if(flag == "3"){
            htmlTitle= "退费记录";
            url="tssMemberReturnPremiumController/ViewRefundDetails.do";
        }
        console.log(url);
        bootbox.hideAll();
        ajaxRequest(url, {
            stuId:stuId
        }, function (html) {
            getTopWin().bootbox.dialog({
                message: html,
                title: htmlTitle,
                className: 'myDialog tssStudentModal'
            });
            $(".modal-header").find(".bootbox-close-button").removeClass("close");
            $(".modal-header").find(".bootbox-close-button").html("");
        }, function () {
            ajaxError("加载页面失败!")
        }, "get", "html")
    }

    function details(that) {
        if(zxc == false){
            var packageId = $(that).attr("packageId");
            ajaxRequest("tssPaymentController/packagePaymentDetails.do", {
                packageId: packageId
            }, function (result) {
                var data=result.data;
                var arr="";
                for (var i = 0; i< data.length; i++) {
                    arr+=('<tr class="addtr">' +
                        '<td></td>' +
                        '<td>'+data[i].paymentType+'</td>' +
                        '<td>'+data[i].contractNumber+'</td>' +
                        '<td>'+data[i].paymentType+'</td>' +
                        '<td>'+data[i].applyStatus+'</td>' +
                        '<td>'+data[i].amount+'</td>' +
                        '<td>'+data[i].discountedPrice+'</td>' +
                        '<td>'+data[i].paymentCode+'</td>' +
                        '<td>'+data[i].updateTime+'</td>' +
                        '<td>'+data[i].userName+'</td>' +
                        '<td>'+data[i].remark+'</td>' +
                        '</tr>');
                }
                console.log(arr);
                $("."+packageId).after(arr);
                zxc = true;
                $(".showtr").html("-")

            }, function () {
                ajaxError("加载页面失败!")
            }, "get", "json")
        } else {
            $(".addtr").remove();
            zxc = false;
            $(".showtr").html("+")
        }
    }

</script>